package siga.visao_academico;

import java.sql.SQLException;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.visao_busca.buscaCurso;
import siga.visao_busca.buscaDisciplina;
import siga.visao_busca.buscaVer;
import siga.visao.index;
import siga.visao.verErros;

public class GestaoCadDisciplina extends javax.swing.JInternalFrame {
    int codigo=0;
    Object[] JOopcoes = {"Sim","Não"};
    /** Creates new form GestaoCadDisciplina */
    public GestaoCadDisciplina() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpPDisc = new javax.swing.JPanel();
        barraFerramentaFonecedor = new javax.swing.JToolBar();
        btNovo = new javax.swing.JButton();
        btAlterar = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        btSalvar = new javax.swing.JButton();
        btRemover = new javax.swing.JButton();
        btSair1 = new javax.swing.JButton();
        btSair = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jtfCodCurso = new javax.swing.JTextField();
        jtfDescCurso = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtfDisciplina = new javax.swing.JTextField();
        jtfSigla = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfCodProfTi = new javax.swing.JTextField();
        jtfDescProfTi = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfCodProfAdj = new javax.swing.JTextField();
        jtfDescProfAdj = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtfCrgHr = new javax.swing.JTextField();
        jtfCredito = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtfBibB = new javax.swing.JTextArea();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtfBibC = new javax.swing.JTextArea();
        jbBuscar = new javax.swing.JButton();
        jbBuscar1 = new javax.swing.JButton();
        jbBuscar2 = new javax.swing.JButton();

        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Cadastro de Disciplinas");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cheque_16x16.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosed(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jpPDisc.setName("jpPDisc"); // NOI18N

        barraFerramentaFonecedor.setFloatable(false);
        barraFerramentaFonecedor.setRollover(true);
        barraFerramentaFonecedor.setName("barraFerramentaFonecedor"); // NOI18N

        btNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/novo_32x32.png"))); // NOI18N
        btNovo.setMnemonic('N');
        btNovo.setText("Novo");
        btNovo.setToolTipText("Inseri um Novo Cadastro");
        btNovo.setFocusable(false);
        btNovo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btNovo.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btNovo.setName("btNovo"); // NOI18N
        btNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovoActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btNovo);

        btAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/editar_32x32.png"))); // NOI18N
        btAlterar.setMnemonic('A');
        btAlterar.setText("Alterar");
        btAlterar.setToolTipText("Alterar um  Cadastro");
        btAlterar.setEnabled(false);
        btAlterar.setFocusable(false);
        btAlterar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btAlterar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btAlterar.setName("btAlterar"); // NOI18N
        btAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlterarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btAlterar);

        btCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cancelar_32x32.png"))); // NOI18N
        btCancelar.setMnemonic('C');
        btCancelar.setText("Cancelar");
        btCancelar.setToolTipText("Cancelar um Cadastro");
        btCancelar.setEnabled(false);
        btCancelar.setFocusable(false);
        btCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btCancelar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btCancelar.setName("btCancelar"); // NOI18N
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btCancelar);

        btSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/salvar_32x32.png"))); // NOI18N
        btSalvar.setMnemonic('S');
        btSalvar.setText("Salvar");
        btSalvar.setToolTipText("Salvar um Cadastro");
        btSalvar.setEnabled(false);
        btSalvar.setFocusable(false);
        btSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSalvar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSalvar.setName("btSalvar"); // NOI18N
        btSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSalvar);

        btRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/remover_32x32.png"))); // NOI18N
        btRemover.setMnemonic('R');
        btRemover.setText("Remover");
        btRemover.setToolTipText("Remove um Cadastro");
        btRemover.setEnabled(false);
        btRemover.setFocusable(false);
        btRemover.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btRemover.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btRemover.setName("btRemover"); // NOI18N
        btRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRemoverActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btRemover);

        btSair1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        btSair1.setMnemonic('B');
        btSair1.setText("Buscar");
        btSair1.setToolTipText("Buscar Disciplina");
        btSair1.setFocusable(false);
        btSair1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSair1.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSair1.setName("btSair1"); // NOI18N
        btSair1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSair1ActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSair1);

        btSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/sair_32x32.png"))); // NOI18N
        btSair.setMnemonic('S');
        btSair.setText("Sair");
        btSair.setToolTipText("Sair da Janela");
        btSair.setFocusable(false);
        btSair.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSair.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSair.setName("btSair"); // NOI18N
        btSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSairActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSair);

        jLabel1.setText("Curso");
        jLabel1.setName("jLabel1"); // NOI18N

        jtfCodCurso.setEditable(false);
        jtfCodCurso.setName("jtfCodCurso"); // NOI18N

        jtfDescCurso.setEditable(false);
        jtfDescCurso.setName("jtfDescCurso"); // NOI18N

        jLabel2.setText("Disciplina");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText("Sigla");
        jLabel3.setName("jLabel3"); // NOI18N

        jtfDisciplina.setEditable(false);
        jtfDisciplina.setName("jtfDisciplina"); // NOI18N

        jtfSigla.setEditable(false);
        jtfSigla.setName("jtfSigla"); // NOI18N

        jLabel4.setText("Professor Titular");
        jLabel4.setName("jLabel4"); // NOI18N

        jtfCodProfTi.setEditable(false);
        jtfCodProfTi.setName("jtfCodProfTi"); // NOI18N

        jtfDescProfTi.setEditable(false);
        jtfDescProfTi.setName("jtfDescProfTi"); // NOI18N

        jLabel5.setText("Professor Adjunto");
        jLabel5.setName("jLabel5"); // NOI18N

        jtfCodProfAdj.setEditable(false);
        jtfCodProfAdj.setName("jtfCodProfAdj"); // NOI18N

        jtfDescProfAdj.setEditable(false);
        jtfDescProfAdj.setName("jtfDescProfAdj"); // NOI18N

        jLabel6.setText("Carga Horária");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText("Crédito");
        jLabel7.setName("jLabel7"); // NOI18N

        jtfCrgHr.setEditable(false);
        jtfCrgHr.setName("jtfCrgHr"); // NOI18N

        jtfCredito.setEditable(false);
        jtfCredito.setName("jtfCredito"); // NOI18N

        jLabel8.setText("Bibliografia Básica");
        jLabel8.setName("jLabel8"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jtfBibB.setColumns(20);
        jtfBibB.setEditable(false);
        jtfBibB.setRows(5);
        jtfBibB.setName("jtfBibB"); // NOI18N
        jScrollPane1.setViewportView(jtfBibB);

        jLabel9.setText("Bibliografia Complementar");
        jLabel9.setName("jLabel9"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jtfBibC.setColumns(20);
        jtfBibC.setEditable(false);
        jtfBibC.setRows(5);
        jtfBibC.setName("jtfBibC"); // NOI18N
        jScrollPane2.setViewportView(jtfBibC);

        jbBuscar.setFont(new java.awt.Font("Dialog", 0, 10));
        jbBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscar.setText("Buscar");
        jbBuscar.setEnabled(false);
        jbBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbBuscar.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jbBuscar.setName("jbBuscar"); // NOI18N
        jbBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscarActionPerformed(evt);
            }
        });

        jbBuscar1.setFont(new java.awt.Font("Dialog", 0, 10));
        jbBuscar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscar1.setText("Buscar");
        jbBuscar1.setEnabled(false);
        jbBuscar1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbBuscar1.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jbBuscar1.setName("jbBuscar1"); // NOI18N
        jbBuscar1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbBuscar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscar1ActionPerformed(evt);
            }
        });

        jbBuscar2.setFont(new java.awt.Font("Dialog", 0, 10));
        jbBuscar2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscar2.setText("Buscar");
        jbBuscar2.setEnabled(false);
        jbBuscar2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbBuscar2.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jbBuscar2.setName("jbBuscar2"); // NOI18N
        jbBuscar2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbBuscar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscar2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpPDiscLayout = new javax.swing.GroupLayout(jpPDisc);
        jpPDisc.setLayout(jpPDiscLayout);
        jpPDiscLayout.setHorizontalGroup(
            jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 774, Short.MAX_VALUE)
            .addGroup(jpPDiscLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jtfDisciplina, javax.swing.GroupLayout.DEFAULT_SIZE, 682, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfSigla, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addContainerGap())
            .addGroup(jpPDiscLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jtfCrgHr)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jtfCredito, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(588, Short.MAX_VALUE))
            .addGroup(jpPDiscLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jpPDiscLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jtfCodCurso, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfDescCurso, javax.swing.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbBuscar)
                .addContainerGap())
            .addGroup(jpPDiscLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jtfCodProfAdj, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfDescProfAdj, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE))
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jtfCodProfTi, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfDescProfTi, javax.swing.GroupLayout.DEFAULT_SIZE, 616, Short.MAX_VALUE))
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbBuscar1)
                    .addComponent(jbBuscar2))
                .addContainerGap())
        );
        jpPDiscLayout.setVerticalGroup(
            jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpPDiscLayout.createSequentialGroup()
                .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfCodCurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfDescCurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jbBuscar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfSigla, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfCodProfTi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfDescProfTi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfCodProfAdj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfDescProfAdj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jpPDiscLayout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfCrgHr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jpPDiscLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfCredito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9)))
                    .addGroup(jpPDiscLayout.createSequentialGroup()
                        .addComponent(jbBuscar1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbBuscar2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpPDiscLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPDisc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPDisc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovoActionPerformed
        btSalvar.setEnabled(!btSalvar.isEnabled());
        btCancelar.setEnabled(!btCancelar.isEnabled());
        btNovo.setEnabled(!btNovo.isEnabled());
        btAlterar.setEnabled(false);
        btRemover.setEnabled(false);
        gerenciaCampos();
        LimpaCampos();
}//GEN-LAST:event_btNovoActionPerformed

    private void btAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlterarActionPerformed
        gerenciaBotao();
        gerenciaCampos();
}//GEN-LAST:event_btAlterarActionPerformed

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        if(btCancelar.isEnabled()){
            if(!btNovo.isEnabled()){
                btSalvar.setEnabled(!btSalvar.isEnabled());
                btCancelar.setEnabled(!btCancelar.isEnabled());
                btNovo.setEnabled(!btNovo.isEnabled());
            }else{
                gerenciaBotao();
            }
            gerenciaCampos();
            LimpaCampos();
        }
}//GEN-LAST:event_btCancelarActionPerformed

    private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
        if(!jtfDescCurso.getText().equals("")){
            if(!jtfDisciplina.getText().equals("")){
                if(!jtfSigla.getText().equals("")){
                    String fcodigo,fproft,fprofad,fcghr,fcred,fbibb,fbibc,dcodigo,dproft,dprofad,dcghr,dcred,dbibb,dbibc;
                    if(codigo==0){fcodigo="";dcodigo="";}else{fcodigo=",codigo";dcodigo=","+String.valueOf(codigo);}
                    if(jtfDescProfTi.getText().equals("")){fproft="";dproft="";}else{fproft=",cod_prof_t";dproft=","+jtfCodProfTi.getText();}
                    if(jtfDescProfAdj.getText().equals("")){fprofad="";dprofad="";}else{fprofad=",cod_prof_a";dprofad=","+jtfCodProfAdj.getText();}
                    if(jtfCrgHr.getText().equals("")){fcghr="";dcghr="";}else{fcghr=",carga_horaria";dcghr=",\""+jtfCrgHr.getText()+"\"";}
                    if(jtfCredito.getText().equals("")){fcred="";dcred="";}else{fcred=",credito";dcred=","+jtfCredito.getText();}
                    if(jtfBibB.getText().equals("")){fbibb="";dbibb="";}else{fbibb=",bb_basica";dbibb=",\""+jtfBibB.getText()+"\"";}
                    if(jtfBibC.getText().equals("")){fbibc="";dbibc="";}else{fbibc=",bb_complementar";dbibc=",\""+jtfBibC.getText()+"\"";}
                    conexao.Inserir("replace into grade_disciplina (cod_emp, cod_curso, descricao, sigla "+fcodigo+fproft+fprofad+fcghr+fcred+fbibb+fbibc+") " +
                            "values("+index.cod_emp+","+jtfCodCurso.getText()+",\""+jtfDisciplina.getText()+"\", \""+jtfSigla.getText()+"\""+dcodigo+dproft+dprofad+dcghr+dcred+dbibb+dbibc+")");
                    gerenciaBotao();
                    gerenciaCampos();
                    LimpaCampos();
                }else{
                   JOptionPane.showMessageDialog(null, "Campo Sigla é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
                   jtfSigla.requestFocus();
                }
            }else{
               JOptionPane.showMessageDialog(null, "Campo Disciplina é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
               jtfDisciplina.requestFocus();
            }
        }else{
           JOptionPane.showMessageDialog(null, "Campo Curso é obrigatório.","Alerta do Sistema.",JOptionPane.INFORMATION_MESSAGE);
           jtfCodCurso.requestFocus();
        }
}//GEN-LAST:event_btSalvarActionPerformed

    private void btRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRemoverActionPerformed
        if (JOptionPane.showOptionDialog(null, "Deseja remover essa Disciplina?\nEsta ação implica em remover todos os registros de Disciplinas dos Diários.", "Removendo Disciplina", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
            if(!jtfCodCurso.getText().equals("") && codigo!=0){
                try {
                    conexao.stm.executeUpdate("delete from grade_disciplina where codigo="+codigo+" and cod_curso="+jtfCodCurso.getText()+" and cod_emp="+index.cod_emp+"");
                } catch (SQLException ex) {
                    verErros.setErro(ex.getMessage());
                }
            }else{
                JOptionPane.showMessageDialog(null, "Erro! Essa Disciplina não pode ser removida sem possuir um curso.","Alerta do Sistema",JOptionPane.ERROR_MESSAGE);
            }
        }
}//GEN-LAST:event_btRemoverActionPerformed

    private void btSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSairActionPerformed
        btCancelarActionPerformed(evt);
        setVisible(false);
        dispose();
}//GEN-LAST:event_btSairActionPerformed

    private void jbBuscar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscar1ActionPerformed
        buscaVer.setTipo("Docente");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            jtfCodProfTi.setText(index.LRpessoa.get(0).toString());
            jtfDescProfTi.setText(index.LRpessoa.get(1).toString());
        }
        index.LRpessoa.add(0, "");
        index.LRpessoa.add(1, "");
    }//GEN-LAST:event_jbBuscar1ActionPerformed

    private void jbBuscar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscar2ActionPerformed
        buscaVer.setTipo("Docente");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            jtfCodProfAdj.setText(index.LRpessoa.get(0).toString());
            jtfDescProfAdj.setText(index.LRpessoa.get(1).toString());
        }
        index.LRpessoa.add(0, "");
        index.LRpessoa.add(1, "");
    }//GEN-LAST:event_jbBuscar2ActionPerformed

    private void btSair1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSair1ActionPerformed
        buscaDisciplina bd = new buscaDisciplina(null,true);
        bd.setLocation((index.tela.width-bd.getWidth())/2, (index.tela.height-bd.getHeight())/2);
        bd.setVisible(true);
        if(!index.LRdisciplina.get(0).equals("")){
            try {
                codigo = Integer.parseInt(index.LRdisciplina.get(0).toString());
                jtfDisciplina.setText(index.LRdisciplina.get(1).toString());
                conexao.Query("select gd.*, gc.descricao as desc_curso, p.descricao as desc_ti, p2.descricao as desc_ad from grade_disciplina gd" +
                        " inner join grade_curso gc on gc.codigo=gd.cod_curso and gc.cod_emp=gd.cod_emp" +
                        " left join pessoas p on p.codigo=gd.cod_prof_t and p.cod_emp=gd.cod_emp" +
                        " left join pessoas p2 on p2.codigo=gd.cod_prof_a and p2.cod_emp=gd.cod_emp" +
                        " where gd.cod_emp=" + index.cod_emp + " and gd.cod_curso=" + bd.bd_curso +
                        " and gd.codigo=" + index.LRdisciplina.get(0));
                conexao.rs.next();
                jtfCodCurso.setText(""+conexao.rs.getString("cod_curso"));
                jtfDescCurso.setText(""+conexao.rs.getString("desc_curso"));
                jtfSigla.setText(""+conexao.rs.getString("sigla"));
                jtfCodProfTi.setText((conexao.rs.getString("cod_prof_t")==null)?"":conexao.rs.getString("cod_prof_t"));
                jtfDescProfTi.setText((conexao.rs.getString("desc_ti")==null)?"":conexao.rs.getString("desc_ti"));
                jtfCodProfAdj.setText((conexao.rs.getString("cod_prof_a")==null)?"":conexao.rs.getString("cod_prof_a"));
                jtfDescProfAdj.setText((conexao.rs.getString("desc_ad")==null)?"":conexao.rs.getString("desc_ad"));
                jtfCredito.setText((conexao.rs.getString("credito")==null)?"":conexao.rs.getString("credito"));
                jtfCrgHr.setText((conexao.rs.getString("carga_horaria")==null)?"":conexao.rs.getString("carga_horaria"));
                jtfBibB.setText((conexao.rs.getString("bb_basica")==null)?"":conexao.rs.getString("bb_basica"));
                jtfBibC.setText((conexao.rs.getString("bb_complementar")==null)?"":conexao.rs.getString("bb_complementar"));
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            }
        }
        index.LRdisciplina.add(0,"");
        index.LRdisciplina.add(1,"");
        index.LRcurso.add(0,"");
        index.LRcurso.add(1,"");
        if(btNovo.isEnabled()){
            btAlterar.setEnabled(true);
            btRemover.setEnabled(true);
        }
    }//GEN-LAST:event_btSair1ActionPerformed

    private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed

    }//GEN-LAST:event_formInternalFrameClosed

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        index.LRdisciplina.add(0,"");
        index.LRcurso.add(0,"");
    }//GEN-LAST:event_formInternalFrameOpened

    private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscarActionPerformed
        buscaCurso bc = new buscaCurso(null,true);
        bc.setLocation((index.tela.width-bc.getWidth())/2, (index.tela.height-bc.getHeight())/2);
        bc.setVisible(true);
        if(buscaCurso.isConfirmaCurso()){
            jtfCodCurso.setText(index.LRcurso.get(0).toString());
            jtfDescCurso.setText(index.LRcurso.get(1).toString());
        }
        index.LRcurso.add(0,"");
        index.LRcurso.add(1,"");
    }//GEN-LAST:event_jbBuscarActionPerformed

    private void gerenciaCampos(){
        jtfDisciplina.setEditable(!jtfCodCurso.isEditable());
        jtfSigla.setEditable(!jtfCodCurso.isEditable());
        jtfCodProfTi.setEditable(!jtfCodCurso.isEditable());
        jtfCodProfAdj.setEditable(!jtfCodCurso.isEditable());
        jtfCredito.setEditable(!jtfCodCurso.isEditable());
        jtfCrgHr.setEditable(!jtfCodCurso.isEditable());
        jtfBibB.setEditable(!jtfCodCurso.isEditable());
        jtfBibC.setEditable(!jtfCodCurso.isEditable());
        jtfCodCurso.setEditable(!jtfCodCurso.isEditable());
        jbBuscar.setEnabled(!jbBuscar2.isEnabled());
        jbBuscar1.setEnabled(!jbBuscar2.isEnabled());
        jbBuscar2.setEnabled(!jbBuscar2.isEnabled());
    }

    private void gerenciaBotao(){
        btNovo.setEnabled(!btNovo.isEnabled());
        btAlterar.setEnabled(!btAlterar.isEnabled());
        btCancelar.setEnabled(!btCancelar.isEnabled());
        btRemover.setEnabled(!btRemover.isEnabled());
        btSalvar.setEnabled(!btSalvar.isEnabled());
    }

    private void LimpaCampos(){
        codigo=0;
        jtfCodCurso.setText("");
        jtfDescCurso.setText("");
        jtfCodProfTi.setText("");
        jtfDescProfTi.setText("");
        jtfCodProfAdj.setText("");
        jtfDescProfAdj.setText("");
        jtfDisciplina.setText("");
        jtfCredito.setText("");
        jtfCrgHr.setText("");
        jtfSigla.setText("");
        jtfBibB.setText("");
        jtfBibC.setText("");
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barraFerramentaFonecedor;
    private javax.swing.JButton btAlterar;
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btNovo;
    private javax.swing.JButton btRemover;
    private javax.swing.JButton btSair;
    private javax.swing.JButton btSair1;
    private javax.swing.JButton btSalvar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbBuscar1;
    private javax.swing.JButton jbBuscar2;
    private javax.swing.JPanel jpPDisc;
    private javax.swing.JTextArea jtfBibB;
    private javax.swing.JTextArea jtfBibC;
    private javax.swing.JTextField jtfCodCurso;
    private javax.swing.JTextField jtfCodProfAdj;
    private javax.swing.JTextField jtfCodProfTi;
    private javax.swing.JTextField jtfCredito;
    private javax.swing.JTextField jtfCrgHr;
    private javax.swing.JTextField jtfDescCurso;
    private javax.swing.JTextField jtfDescProfAdj;
    private javax.swing.JTextField jtfDescProfTi;
    private javax.swing.JTextField jtfDisciplina;
    private javax.swing.JTextField jtfSigla;
    // End of variables declaration//GEN-END:variables

}
